package dudghk;

import java.util.Scanner;

public class J05Ex35Charges {
	//잔돈을 계산하는 프로그램

	public static void main(String[] args){
		//1.뵨수선언
		int pay = 0;         //청구금액
		int money = 0;   //지불금액
	    int charge=0;       //잔돈
		int W50000=0;    //거스름돈
		int W10000=0;    //거스름돈
		int W5000=0;     //거스름돈
		int W1000=0;    //거스름돈
		int W500=0;     //거스름돈
		int W100=0;     //거스름돈
		int W50=0;      //거스름돈
		int W10=0;     //거스름돈
		int W1=0;       //거스름돈
		Scanner sc=new Scanner(System.in); //입력값 받아야 함
		String result="";
		
		
		//2.잔돈계산
		System.out.println("청구금액을 입력");
		pay=sc.nextInt();
		System.out.println("지불금액을 입력");
		money=sc.nextInt();
		
		charge= money -pay;
		
		//잔돈50000계산
		W50000=charge/ 50000;
		
		//잔돈10000계산
		charge=charge%50000;
		W10000=charge/10000;
		
		//잔돈5000계산
		charge=charge%10000;
		W5000=charge/5000;
		
		//잔돈1000계산
		charge=charge%5000;
		W1000=charge/1000;
		
		//잔돈500계산
		charge=charge%1000;
		W500=charge/500;
		
		//잔돈100계산
		charge=charge%500;
		W100=charge/100;
		
		//잔돈 50계산
		charge=charge%100;
		W50=charge/50;
		
		//잔돈 10계산
		charge=charge%50;
		W10=charge/10;
		
		//잔돈 1계산
		charge=charge%10;
		W1=charge/1;
		
				
		
		
		
		
		
		//3.결과출력
		System.out.println("거스름돈은 다음과 같다");
		result +="50000원권 : " +W50000+"\n";		
		result +="10000원권 : " +W10000+"\n";
		result +="5000원권 : " +W5000+"\n";
		result +="1000원권 : " +W1000+"\n";
		result +="500원권 : " +W500+"\n";
		result +="100원권 : " +W100+"\n";
		result +="50원권 : " +W50+"\n";
		result +="10원권 : " +W10+"\n";
		result +="1원권 : " +W1+"\n";
		
		System.out.println(result);
	
	}

}
